package com.linshidream.intrachat.simplenio;

import com.linshidream.intrachat.simplenio.packet.handler.LengthFieldMessageCodec;
import com.linshidream.intrachat.simplenio.packet.boots.PacketEventLoopGroup;
import com.linshidream.intrachat.simplenio.packet.boots.PacketServerBootstrap;
import com.linshidream.intrachat.simplenio.packet.handler.MessageCodec;
import com.linshidream.intrachat.simplenio.packet.handler.PacketHandler;
import com.linshidream.intrachat.simplenio.packet.handler.ServerPacketHandler;

/**
 * Created on 2025/8/17 16:39
 *
 * @author linshidream
 * @version 1.0.0
 * @description
 */

public class PacketServer {
    public static void main(String[] args) {

        PacketEventLoopGroup workGroup = new PacketEventLoopGroup(4);

        MessageCodec codec = new LengthFieldMessageCodec();
        PacketHandler handler = new ServerPacketHandler();

        try {
            PacketServerBootstrap bootstrap = new PacketServerBootstrap();
            bootstrap.group(workGroup)
                    .childHandler(codec, handler)
                    .bind(10020)
                    .sync();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            workGroup.shutdownGracefully();
        }
    }
}
